package ru.paswd.marketprice.data.repositories

import android.content.Context
import ru.paswd.marketprice.Server
import ru.paswd.marketprice.api.dto.Page
import ru.paswd.marketprice.api.dto.Product
import ru.paswd.marketprice.listener.OnProcessListener

object ProductsRepository : Repository() {
    fun requestAll(context: Context, name: String?, category: String?,
                   listener: OnProcessListener<Page<Product>>) {
        Server.withContext(context).getApi()
            .getProducts(name, category)
            .enqueue(RepositoryCallback(listener))

        super.request(context, listener) { api -> api.getProducts(name, category) }
    }
}